﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UnityEngine;

class MachineGunnery_27 : Weapon
{
    GameObject m_MultiFireShip;
    Vector3 m_MultiFirePosition;
    Vector3 m_MultiFireDirection;

    int m_MagazineSize = 0;
    int m_MagazineSizeMax = 120;
    float m_ShotVelocity = 0.08f;
    float m_ContinueFireTimeCount = 0;
    public MachineGunnery_27()
    {
        m_Price = 550;
        m_Type = ItemsType.WEAPON_MIDDLE_KINETICS_MACHINE_GUNNERY;
        m_Speciality = Speciality.MAIN;
        ResearchInfluence = InfluenceMG.INFLUENCE_FIRE_STAR;
        ShutRange = 9.5f;
        ShutVelocity = 14f;
        BulletFlyVelocity = 6;
        Damage = 12f;
        TurnSpeed = 60f;
        m_ShotErrorValueMax = 45;
        m_ShotErrorValueIncrement = 0.8f;
        m_ExplotionScale = 0.4f;
        Name = "多管机炮-27";
        Perview = "Textures/Weapon/WeaponMiddle/MachineGunnery-27";
        WeaponResource = "Perfabs/Weapon/Middle/MachineGunnery-27";
        BulletResource = "Perfabs/Bullet/LiveBullet";
        m_FireAudioResouce = "Perfabs/Audio/Pong";
        m_Level = Level.LEVEL_MIDDLE;
        Description = "超强大的火力，任何舰船都不想硬扛下他的一轮炮击。常用在战场上做火力压制，缺点是火炮长时间射击导致炮管过热需要较长的冷却时间，且快速炮击让射击误差飞快的叠加。";

    }
    public override FlyItem Fire(GameObject ship, WeaponSlot slot, Vector3 position, Vector3 direction)
    {
        if (ship)
            m_Ship = ship.GetComponent<Ship>();
        Slot = slot;
        m_MultiFireShip = ship;
        m_MultiFireDirection = direction;
        m_MagazineSize = m_MagazineSizeMax;
        return null;
    }


    public override int update()
    {
        base.update();

        if (m_MagazineSize > 0)
        {
            m_ContinueFireTimeCount += Time.deltaTime;
            if (m_ContinueFireTimeCount >= m_ShotVelocity)
            {
                m_MagazineSize--;
                m_ContinueFireTimeCount = 0;
                base.Fire(m_MultiFireShip, Slot, Slot.transform.position, Slot.CurrentWeaponDirection);
            }
        }
        return 1;
    }

}